/*
  This code was created by Payk using the tutorial
  which can be found at: http://tfc.duke.free.fr/coding/md2-specs-en.html
  It was higly optimzed for libnds to work at 60FPS.
  Please do not remove this credit or claim that it was your code.
*/

#ifndef MD2MODELS_CPP
#define MD2MODELS_CPP

#include "MD2.h"
#include <stdio.h>


//Functions
void RenderMD2Model (int n, MD2Entity &Model, bool &ModelEnable){	
 
	int i, j,stnum,vertnum;
	//MD2Entity mod=Models[num];
	if ( (n < 0) || (n > Model.header.num_frames - 1))n=Model.header.num_frames - 1;
	if(ModelEnable==false)return;
	
	nds_vertex_t* vert=Model.frms[n].verts;
		glBegin (GL_TRIANGLES);		
			for (i = 0; i < Model.header.num_tris; ++i){
				for (j = 0; j < 3; ++j){	
					stnum=Model.tris[i].st[j];
					vertnum=Model.tris[i].vertex[j];
					glTexCoord2t16 (Model.uvs[stnum].s, Model.uvs[stnum].t);
					glVertex3v16 (vert[vertnum].v[0],vert[vertnum].v[1], vert[vertnum].v[2]);     
				}
			}
		glEnd ();
}


#endif
